import java.util.HashSet;

public class Exercise17_01{
    public static void main(String[] args){
        HashSet<Triangle> hs = new HashSet<Triangle>();
        Triangle t1 = new Triangle(2, 3);
        Triangle t2 = new Triangle(2, 4);
        Triangle t3 = new Triangle(2, 3);
        Triangle t4 = new Triangle(4, 5);
        
        hs.add(t1);
        hs.add(t2);
        hs.add(t3);
        hs.add(t4);
        
        for(Triangle item : hs){
            System.out.println(item);
        }
    }
}

class Triangle{
    int a;
    int b;
    
    public Triangle(int a, int b){
        this.a = (a < b) ? a : b;
        this.b = (a < b) ? b : a;
    }
    
    public int hashCode(){
        return a;
    }
    
    public boolean equals(Object o){
        if(this == o){
            return true;
        }
        
        if(o.getClass() == Triangle.class){
            Triangle tr = (Triangle)o;
            return tr.a == this.a && tr.b == this.b;
        }
        
        return false;
    }
    
    public String toString(){
        return "[ className: " + this.getClass().getName() + " a: " + a + ", b: " + b + " ]";
    }
}